package com.algo.animal;

import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
public class Pig implements FoodStuffAware {

    private FoodStuff foodStuff;

    public Pig() {
        System.out.println("Pig 无参构造");
    }

    @PostConstruct
    public void initMethod() {
        System.out.println("Pig initMethod invoke ...");
    }

    @PreDestroy
    public void destroyMethod() {
        System.out.println("Pig destroyMethod invoke ...");
    }

    public void eat() {
        System.out.println("Pig eat " + foodStuff.getName());
    }

    @Override
    public void setFoodStuff(FoodStuff foodStuff) {
        this.foodStuff = foodStuff;
    }
}
